<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
    </script>
</head>
<body>
<div class="banner">
 555
</div>
<script> 
// var commonHeader = { // 公共header
    //     "Accept": "application/json",
    //    "Authorization": "Bear " + "..."
    // } 
    // //公共ajax封装
    // function ajax(url, type, params, beforefn, successfn, errorfn) {
    //     $.ajax({
    //         url: url,
    //         type: type,
    //         headers: commonHeader,
    //         data: params,
    //         beforeSend:function(res){
    //             beforefn(res)
    //         },
    //         success: function (res) {
    //             successfn(res);
    //         },
    //         error: function (res) {
    //             errorfn(res);            
    //         },
    //         complete:function(){
    //         }
    //     });
    // }
//参数名ASCII码从小到大排序；0,A,B,a,b;
//"sign": "262507867f9bc1b9ee417b0863aed431"
var jsonobj ={
    "sdkver": "1.0.0",
    "duid": "6389c5d88f74f99da77079378a83c10f",
    "uname": "hejdhfbf",
    "ptid": 1,
    "gid": 1000123,
    "refid": "ANDROID",
    "version": "1.12.0",
    "time": 1594261336,
    "token": "96bfGlU65BHznAf2iZ5Rhwefi%2B15BHEaSniRHvyb6pL7nTeLNUacj%2FywyDvzjXF9GuinuIiyNIKkzYLA3SUt3inw%2F6bYC8iFD1TIrljNEEjfy8H6hYd5t4EAycUBMo5oatvwDZoqhluTqkmOltMyURlV",
    "gname": "如懿秘史",
    "doid": "202007091022157754754F39",
    "dpt": "月卡",
    "dcn": "钻石",
    "dsid": "24823",
    "dsname": "花月吟24服",
    "dext": "202007091022157754754F39",
    "drid": "26028803749",
    "drname": "古龙雪卉",
    "drlevel": 1,
    "money": 25.00,
    "dradio": 10,
    "moid": "556CFEE2B55A2B62B0DD1F57C7FEAC36",
    "ig": 1,
    "os": 1,
    "lastPway": "alipay",
    "pway": "xzwxpa"
  }
  paysignjs(jsonobj)
function paysignjs (jsonobj) {
  var signstr = obj2str(jsonobj)
  //var key="457acd381422cb6cb7d2e833c075a006";
 // signstr = signstr + '&key=' + key;
 signstr = signstr
  console.log(signstr)
  // var sign = CryptoJS(signstr);
  // console.log(sign,'CryptoJSCryptoJSCryptoJSCryptoJSCryptoJS')
  // paySign = sign;
  // return sign.toUpperCase()
}
//object转string,用于签名计算
function obj2str(args) {
  var keys = Object.keys(args)
  keys = keys.sort() //参数名ASCII码从小到大排序（字典序）；
  var newArgs = {}
  keys.forEach(function (key) {
    if (args[key] != "" && args[key] != 'undefined') {  //如果参数的值为空不参与签名；
      newArgs[key] = args[key]  //参数名区分大小写；
    }
    
  })
  var string = ''
  for (var k in newArgs) {
    string += k + '=' + newArgs[k]
  }
  string = string.substr(1)
  return string
}
function Student (name, age, sex) {
            this.name = name;
            this.age = age;
            this.sex = sex;
            this.sayHello = function (a,b) {
                console.log(a,b,this.sex);
            }
        }
        var student3 = new Student('小明', 20, 'male');
        console.log(student3);
        console.log(student3.name);
        student3.sayHello(112,60);

class Fun {
    constructor(a,b){
        this.a = a;
        this.b = b;
    }
    showA() {
        console.log(this.a,this.b);
    }
}
var fun = new Fun(1,2,3);
fun.showA();//1

// class Point {
//   constructor(x, y) {
//     this.x = x;
//     this.y = y;
//   }

//   toString() {
//     console.log (this.x ,this.y );
//   }
// }
// new toString(1,3)

let s2 = Symbol('a');
console.log(s2)
const items = ["zero", "one", "two"];
const it = items[Symbol.iterator]();
console.log(it.next())
it.next();
// const xiyou = ['a','b','c']
// for(let v of xiyou){
//     console.log(v)
// }
const banji = {
    name:"a",
    stus:[
        'xming',
        'king',
        'aio',
        'admin'
    ],
    [Symbol.iterator](){
        let index = 0;
        let _this =this;
        return {
            next:function(){
                if(index < _this.stus.length){
                    const result = { value:_this.stus[index],done:false };
                    index++
                    return result;
                }else{
                    return {value:undefined,done:true};
                }
            }
        }
    }
}
for(let v of banji){
    console.log(v)
}

function * gen(){
  //  console.log("hell");
   yield 'a';
   //console.log("aaa");
   yield 'b';
   //console.log("bbb");
   yield 'c';
   //console.log("ccc")
}
// let iteratpr = gen()
// iteratpr.next();
// iteratpr.next();
// iteratpr.next();
// iteratpr.next();
for(let v of gen() ){
  console.log(v)
}
function getUsers(){
    setTimeout(()=>{
        let data = '用户数据'
        iteratpr.next(data)
    },1000);
}
function getOrders(users){
  console.log(users)
    setTimeout(()=>{
        let data = '订单数据'
         iteratpr.next(data)
    },1000);
}
function getGoods(){
    setTimeout(()=>{
        let data = '商品数据'
    },1000);
}

function * gen(){
    let users = yield getUsers();
    
    let orders = yield getOrders(users);
    
    let goods = yield getGoods()
}
let iteratpr = gen("aaa")
iteratpr.next();
const p =new Promise((resolve,reject)=>{
    const xhr = new XMLHttpRequest();
    xhr.open("GET","https://api.apiopen.top/getJoke")
    xhr.send();
    xhr.onreadystatechange = function(){
        if(xhr.readyState === 3){
            if(xhr.status>=200 && xhr.status<300){  
              resolve(xhr.readyState)
            }else{
              reject(xhr.readyState)
            }
        }
    }
})
window.jQuery.ajax = ({method,path,body,headers})=>{//ES6语法
   //进行Promise封装
    return new Promise((resolve,reject)=>{//这句话是套路,记住
        let request = new XMLHttpRequest();
        request.open(method,path);//配置

        for (const key in headers) {//遍历header,设置响应头
            let value = headers[key];
            request.setRequestHeader(key,value);
        }
        request.send(body);//发送,并配置响应体

        request.onreadystatechange = ()=>{
            if(request.readyState ===4){
                if ( request.status>=200&&request.status<=400){
                    resolve.call(undefined,request.responseText);//执行成功函数
                }else if(request.status>=400){
                    reject.call(undefined,request);//执行失败函数
                }
            }
        }
    })
}
$.ajax({
        method:"get",
        path:"https://api.apiopen.top/getJoke",
        // body:"username=mtt&password=1",
        // headers:{
        //     "content-type":'application/x-www-form-urlencoded',
        //     "mataotao":18
        // }
    }).then(
        (responseText)=>{console.log(responseText);},//成功就调用这个函数
        (request)=>{console.log(request);}//失败就调用这个函数
    )
//调用myButton.addEventListener("click",(e)=>{
    //使用ajax
//     $.ajax({
//         method:"get",
//         path:"https://api.apiopen.top/getJoke",
//         body:"username=mtt&password=1",
//         headers:{
//             "content-type":'application/x-www-form-urlencoded',
//             "mataotao":18
//         }
//     }).then(
//         (responseText)=>{console.log(responseText);},//成功就调用这个函数
//         (request)=>{console.log(request);}//失败就调用这个函数
//     )
// })
p.then(function(){
  console.log(value,"value")
},function(reason){
  console.error('reason')
})
let arr =[1,2,3,4,5,6,7]
console.log(arr)
let b = 0b1010
console.log(b)
阿里云可视图
https://g2.antv.vision/zh/examples/gallery
</script>
</body>
</html>